home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / sml_nj / cml-098.lha / cml-0.9.8 / src / trace-cml-sig.sml < prev    next >
Encoding:
Text File  |  1993-02-15  |  3.1 KB  |  99 lines

  1. (* trace-cml-sig.sml
  2.  *
  3.  * COPYRIGHT (c) 1992 AT&T Bell Laboratories
  4.  *
  5.  * This module provides rudimentary debugging support in the form of mechanisms
  6.  * to control debugging output, and to monitor thread termination.  This
  7.  * version of this module is adapted from Cliff Krumvieda's utility for tracing
  8.  * CML programs.  It provides three facilities: trace modules, for controlling
  9.  * debugging output; thread watching, for detecting thread termination; and
  10.  * a mechanism for reporting uncaught exceptions on a per thread basis.
  11.  *)
  12.  
  13. signature TRACE_CML =
  14.   sig
  15.  
  16.     structure CML : CONCUR_ML
  17.     structure CIO : CONCUR_IO
  18.  
  19.  
  20.   (** Trace modules **
  21.    *
  22.    * The basic idea is that one defines a heirarchy of ``trace
  23.    * modules,'' which provide valves for debugging output.
  24.    *)
  25.  
  26.     type trace_module
  27.  
  28.   (* where to direct trace output to *)
  29.     datatype trace_to
  30.       = TraceToOut
  31.       | TraceToErr
  32.       | TraceToNull
  33.       | TraceToFile of string
  34.       | TraceToStream of CIO.outstream
  35.  
  36.     val setTraceFile : trace_to -> unit
  37.     (* Direct the destination of trace output.  Note: TraceToStream
  38.      * can only be specified as a destination, if CML is running.
  39.      *)
  40.  
  41.     val traceRoot : trace_module
  42.     (* the root module of the trace hierarchy *)
  43.  
  44.     exception NoSuchModule
  45.  
  46.     val traceModule : (trace_module * string) -> trace_module
  47.     val nameOf : trace_module -> string
  48.     (* return the name of the module *)
  49.     val moduleOf : string -> trace_module
  50.     (* return the module specified by the given string, or raise
  51.      * NoSuchModule if none exists.
  52.      *)
  53.  
  54.     val traceOn : trace_module -> unit
  55.     (* turn tracing on for a module and its descendents *)
  56.     val traceOff : trace_module -> unit
  57.     (* turn tracing off for a module and its descendents *)
  58.     val traceOnly : trace_module -> unit
  59.     (* turn tracing on for a module (but not for its descendents) *)
  60.     val amTracing : trace_module -> bool
  61.     (* return true if this module is being traced *)
  62.  
  63.     val status : trace_module -> (trace_module * bool) list
  64.     (* return a list of the registered modules dominated by the given
  65.      * module, and their status.
  66.      *)
  67.  
  68.     val trace : (trace_module * (unit -> string list)) -> unit
  69.     (* conditionally generate tracing output *)
  70.  
  71.  
  72.   (** Thread watching **)
  73.   
  74.     val watcher : trace_module
  75.     (* controls printing of thread watching messages; the module's name
  76.      * is "/ThreadWatcher/"
  77.      *)
  78.     val watch : (string * CML.thread_id) -> unit
  79.     (* watch the given thread for unexpected termination *)
  80.     val unwatch : CML.thread_id -> unit
  81.     (* stop watching the named thread *)
  82.  
  83.   (** Uncaught exception handling **)
  84.  
  85.     val setUncaughtFn : ((CML.thread_id * exn) -> unit) -> unit
  86.     (* this sets the default uncaught exception action. *)
  87.     val setHandleFn : ((CML.thread_id * exn) -> bool) -> unit
  88.     (* add an additional uncaught exception action.  If the action returns
  89.      * true, then no further action is taken.  This can be used to handle
  90.      * application specific exceptions.
  91.      *)
  92.     val resetUncaughtFn : unit -> unit
  93.     (* this resets the default uncaught exception action to the system default,
  94.      * and removes any layered actions.
  95.      *)
  96.  
  97.   end; (* TRACE_CML *)
  98.  
  99.